﻿using UnityEngine;
using System.Collections;

public class DoorController : MonoBehaviour 
{
	public Transform endPoint;
	public float speed;
	public int targetCount = 4;
	public GameObject door;

	private Transform MyTransform;
	
	void Awake()
	{
		MyTransform = transform;
	}

	public void UpdateCounter()
	{
		--targetCount;
	}

	void Update()
	{	
		if(targetCount <= 0)
		{
			door.transform.position = Vector3.Lerp (MyTransform.position, endPoint.position, speed);
		}
	}
}
